package com.example.leetdemo.plan1;

public class Sword006 {
    public int[] twoSum(int[] numbers, int target) {
        int p = 0, q = numbers.length - 1;
        while (numbers[p] + numbers[q] != target) {
            int temp = numbers[p] + numbers[q];
            if (temp > target) {
                q--;
            } else if (temp < target){
                p++;
            }
        }
        return new int[] {p, q};
    }
}
